package aptech.eproject.logictics.db;

import java.io.Serializable;
import javax.persistence.*;

/**
 * The persistent class for the ACCOUNT database table.
 * 
 */
@Entity
@Table(name = "ACCOUNT")
@NamedQueries({
    @NamedQuery(name = "findAccounts", query = "SELECT a FROM Account a WHERE a.role='Employee' OR a.role='Manager'"),
    @NamedQuery(name = "findAccountsByFullName", query = "SELECT a FROM Account a WHERE a.fullName LIKE ?1 AND (a.role='Employee' OR a.role='Manager')")
})
public class Account implements Serializable {

    private static final long serialVersionUID = 1L;
    private String userName;
    private String address;
    private String email;
    private String fullName;
    private boolean isBlocked;
    private String password;
    private String phoneNumber;
    private Role role;
    private Branch branch;

    public Account() {
    }

    @Id
    @Column(name = "USER_NAME", nullable = false)
    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Column(name = "ADDRESS", nullable = false)
    public String getAddress() {
        return this.address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Column(name = "EMAIL", nullable = false)
    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Column(name = "FULL_NAME", nullable = false)
    public String getFullName() {
        return this.fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    @Column(name = "IS_BLOCKED", nullable = true)
    public boolean getIsBlocked() {
        return this.isBlocked;
    }

    public void setIsBlocked(boolean isBlocked) {
        this.isBlocked = isBlocked;
    }

    @Column(name = "PASSWORD", nullable = false)
    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Column(name = "PHONE_NUMBER", nullable = true)
    public String getPhoneNumber() {
        return this.phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    @Enumerated(EnumType.STRING)
    @Column(name = "ROLE", nullable = false)
    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    //bi-directional many-to-one association to Branch
    @ManyToOne
    @JoinColumn(name = "BRANCH_ID", nullable = true)
    public Branch getBranch() {
        return this.branch;
    }

    public void setBranch(Branch branch) {
        this.branch = branch;
    }
}
